package com.storeroompda.utils;

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class StringUtil {



    private volatile static StringUtil stringUtil;

    public StringUtil(){

    }

    public static  StringUtil getDateUtilInstance() {
        if (stringUtil == null) {
            synchronized (StringUtil.class) {
                if (stringUtil == null) {
                    stringUtil = new StringUtil();
                }
            }
        }
        return stringUtil;
    }



    //每三位以逗号进行分隔
    public String addComma(String str) {
        DecimalFormat decimalFormat = new DecimalFormat(",###");
        return decimalFormat.format(Double.parseDouble(str));
    }

    //保留小数点后两位
    public  Double saveOneBitTwo(Double d){
        BigDecimal bd = new BigDecimal(d);
        Double tem = bd.setScale(2,BigDecimal.ROUND_FLOOR).doubleValue();
        return tem;
    }
}
